package com.kh.rationaldrugreview.enums;

/**
 * 风险等级枚举
 * Risk Level Enumeration
 */
public enum RiskLevel {
    
    /**
     * 无风险 - 妊娠A级、无相互作用、完全适用
     */
    NONE(0, "无风险", "No Risk", "#28a745"),
    
    /**
     * 低风险 - 妊娠B级、轻微相互作用、需注意但可使用
     */
    LOW(1, "低风险", "Low Risk", "#ffc107"),
    
    /**
     * 中风险 - 妊娠C级、年龄限制、中度相互作用、需要监测
     */
    MEDIUM(2, "中风险", "Medium Risk", "#fd7e14"),
    
    /**
     * 高风险 - 妊娠D级、相对禁忌、重度器官功能不全、需调整剂量
     */
    HIGH(3, "高风险", "High Risk", "#dc3545"),
    
    /**
     * 极高风险 - 妊娠X级、绝对禁忌、严重相互作用、危及生命
     */
    CRITICAL(4, "极高风险", "Critical Risk", "#6f42c1");
    
    private final int level;
    private final String chineseName;
    private final String englishName;
    private final String color;
    
    RiskLevel(int level, String chineseName, String englishName, String color) {
        this.level = level;
        this.chineseName = chineseName;
        this.englishName = englishName;
        this.color = color;
    }
    
    public int getLevel() {
        return level;
    }
    
    public String getChineseName() {
        return chineseName;
    }
    
    public String getEnglishName() {
        return englishName;
    }
    
    public String getColor() {
        return color;
    }
    
    /**
     * 根据风险分值获取风险等级
     */
    public static RiskLevel fromScore(int score) {
        if (score >= 90) return CRITICAL;
        if (score >= 60) return HIGH;
        if (score >= 30) return MEDIUM;
        if (score > 0) return LOW;
        return NONE;
    }
    
    /**
     * 获取更严重的风险等级
     */
    public static RiskLevel max(RiskLevel level1, RiskLevel level2) {
        return level1.level > level2.level ? level1 : level2;
    }
    
    /**
     * 判断是否为高危风险
     */
    public boolean isHighRisk() {
        return this.level >= HIGH.level;
    }
    
    /**
     * 判断是否需要特别注意
     */
    public boolean requiresAttention() {
        return this.level >= MEDIUM.level;
    }
}